﻿using APP.HELPER.Data.Helper;
using System; using Extra.ERP;
using System.ComponentModel;
using System.Data.SqlClient;

namespace HRM.CORE
{
    public class HRM_CANDIDATE_MARK
    {
        private string m_CandidateCode;
        private string m_Comment;
        private DateTime m_Date1;
        private DateTime m_Date2;
        private DateTime m_Date3;
        private bool m_IsPass;
        private double m_Mark1;
        private double m_Mark2;
        private double m_Mark3;
        private Guid m_MarkID;

        public HRM_CANDIDATE_MARK()
        {
            this.m_MarkID = Guid.Empty;
            this.m_CandidateCode = "";
            this.m_Mark1 = 0.0;
            this.m_Mark2 = 0.0;
            this.m_Mark3 = 0.0;
            this.m_Date1 = DateTime.Now;
            this.m_Date2 = DateTime.Now;
            this.m_Date3 = DateTime.Now;
            this.m_Comment = "";
            this.m_IsPass = true;
        }

        public HRM_CANDIDATE_MARK(Guid MarkID, string CandidateCode, double Mark1, double Mark2, double Mark3, DateTime Date1, DateTime Date2, DateTime Date3, string Comment, bool IsPass)
        {
            this.m_MarkID = MarkID;
            this.m_CandidateCode = CandidateCode;
            this.m_Mark1 = Mark1;
            this.m_Mark2 = Mark2;
            this.m_Mark3 = Mark3;
            this.m_Date1 = Date1;
            this.m_Date2 = Date2;
            this.m_Date3 = Date3;
            this.m_Comment = Comment;
            this.m_IsPass = IsPass;
        }

        public string Get(string CandidateCode)
        {
            string str = "";
            string[] myParams = new string[] { "@CandidateCode" };
            object[] myValues = new object[] { CandidateCode };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_CANDIDATE_MARK_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_MarkID = reader.GetGuid(reader.GetOrdinal("MarkID"));
                    this.m_CandidateCode = Convert.ToString(reader["CandidateCode"]);
                    this.m_Mark1 = Convert.ToDouble(reader["Mark1"]);
                    this.m_Mark2 = Convert.ToDouble(reader["Mark2"]);
                    this.m_Mark3 = Convert.ToDouble(reader["Mark3"]);
                    this.m_Date1 = Convert.ToDateTime(reader["Date1"]);
                    this.m_Date2 = Convert.ToDateTime(reader["Date2"]);
                    this.m_Date3 = Convert.ToDateTime(reader["Date3"]);
                    this.m_Comment = Convert.ToString(reader["Comment"]);
                    this.m_IsPass = Convert.ToBoolean(reader["IsPass"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Update()
        {
            string[] myParams = new string[] { "@MarkID", "@CandidateCode", "@Mark1", "@Mark2", "@Mark3", "@Date1", "@Date2", "@Date3", "@Comment", "@IsPass" };
            object[] myValues = new object[] { this.m_MarkID, this.m_CandidateCode, this.m_Mark1, this.m_Mark2, this.m_Mark3, this.m_Date1, this.m_Date2, this.m_Date3, this.m_Comment, this.m_IsPass };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_CANDIDATE_MARK_Update", myParams, myValues);
        }

        public string Update(Guid MarkID, string CandidateCode, double Mark1, double Mark2, double Mark3, DateTime Date1, DateTime Date2, DateTime Date3, string Comment, bool IsPass)
        {
            string[] myParams = new string[] { "@MarkID", "@CandidateCode", "@Mark1", "@Mark2", "@Mark3", "@Date1", "@Date2", "@Date3", "@Comment", "@IsPass" };
            object[] myValues = new object[] { MarkID, CandidateCode, Mark1, Mark2, Mark3, Date1, Date2, Date3, Comment, IsPass };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_CANDIDATE_MARK_Update", myParams, myValues);
        }

        public string Update(SqlConnection myConnection, Guid MarkID, string CandidateCode, double Mark1, double Mark2, double Mark3, DateTime Date1, DateTime Date2, DateTime Date3, string Comment, bool IsPass)
        {
            string[] myParams = new string[] { "@MarkID", "@CandidateCode", "@Mark1", "@Mark2", "@Mark3", "@Date1", "@Date2", "@Date3", "@Comment", "@IsPass" };
            object[] myValues = new object[] { MarkID, CandidateCode, Mark1, Mark2, Mark3, Date1, Date2, Date3, Comment, IsPass };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_CANDIDATE_MARK_Update", myParams, myValues);
        }

        public string Update(SqlTransaction myTransaction, Guid MarkID, string CandidateCode, double Mark1, double Mark2, double Mark3, DateTime Date1, DateTime Date2, DateTime Date3, string Comment, bool IsPass)
        {
            string[] myParams = new string[] { "@MarkID", "@CandidateCode", "@Mark1", "@Mark2", "@Mark3", "@Date1", "@Date2", "@Date3", "@Comment", "@IsPass" };
            object[] myValues = new object[] { MarkID, CandidateCode, Mark1, Mark2, Mark3, Date1, Date2, Date3, Comment, IsPass };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_CANDIDATE_MARK_Update", myParams, myValues);
        }

        [Category("Column"), DisplayName("CandidateCode")]
        public string CandidateCode
        {
            get
            {
                return this.m_CandidateCode;
            }
            set
            {
                this.m_CandidateCode = value;
            }
        }

        [Category("Column"), DisplayName("Comment")]
        public string Comment
        {
            get
            {
                return this.m_Comment;
            }
            set
            {
                this.m_Comment = value;
            }
        }

        [Category("Column"), DisplayName("Date1")]
        public DateTime Date1
        {
            get
            {
                return this.m_Date1;
            }
            set
            {
                this.m_Date1 = value;
            }
        }

        [DisplayName("Date2"), Category("Column")]
        public DateTime Date2
        {
            get
            {
                return this.m_Date2;
            }
            set
            {
                this.m_Date2 = value;
            }
        }

        [DisplayName("Date3"), Category("Column")]
        public DateTime Date3
        {
            get
            {
                return this.m_Date3;
            }
            set
            {
                this.m_Date3 = value;
            }
        }

        [DisplayName("IsPass"), Category("Column")]
        public bool IsPass
        {
            get
            {
                return this.m_IsPass;
            }
            set
            {
                this.m_IsPass = value;
            }
        }

        [DisplayName("Mark1"), Category("Column")]
        public double Mark1
        {
            get
            {
                return this.m_Mark1;
            }
            set
            {
                this.m_Mark1 = value;
            }
        }

        [Category("Column"), DisplayName("Mark2")]
        public double Mark2
        {
            get
            {
                return this.m_Mark2;
            }
            set
            {
                this.m_Mark2 = value;
            }
        }

        [Category("Column"), DisplayName("Mark3")]
        public double Mark3
        {
            get
            {
                return this.m_Mark3;
            }
            set
            {
                this.m_Mark3 = value;
            }
        }

        [DisplayName("MarkID"), Category("Primary Key")]
        public Guid MarkID
        {
            get
            {
                return this.m_MarkID;
            }
            set
            {
                this.m_MarkID = value;
            }
        }

        public string ProductName
        {
            get
            {
                return "Class HRM_CANDIDATE_MARK";
            }
        }

        public string ProductVersion
        {
            get
            {
                return "1.0.0.0";
            }
        }
    }
}

